<?php


namespace app\service;


use app\dao\PayOrderDao;

class PayOrderService
{
    private $PayOrderDao;

    public function __construct()
    {
        $this->PayOrderDao = new PayOrderDao();
    }

    public function getPayOrder($id){
        return $this->PayOrderDao->customQuery()->filterById($id)->getOne();
    }

    public function addPayOrder($user_id , $pay_id , $money , $pay_type){
        return $this->PayOrderDao->save([
            'user_id' => $user_id,
            'pay_id' => $pay_id,
            'money' => $money,
            'pay_type' => $pay_type
        ]);
    }

    public function editPayOrder($id , $data){
        $editData = [];
        empty($data['user_id']) || $editData['user_id'] = $data['user_id'];
        empty($data['pay_id']) || $editData['pay_id'] = $data['pay_id'];
        empty($data['money']) || $editData['money'] = $data['money'];
        empty($data['pay_type']) || $editData['pay_type'] = $data['pay_type'];

        return $this->PayOrderDao->edit($id , $editData);
    }
}